package workers;

import java.util.concurrent.BlockingQueue;

import model.Software;
import workerUIs.SpecificationStepFrame;
import workerUIs.StepFrame;
import workflow.step.SpecificationStep;

/**
 * SpecificationStepWorker class.
 * 
 * @author Mark Czotter
 * @author Miklos Szennai
 * 
 */
public class SpecificationStepWorker extends AbstractStepSwingWorker {

	private final String desiredName;
	private final BlockingQueue<Software> outputQueue;
	protected final StepFrame nextFrame;

	public SpecificationStepWorker(SpecificationStepFrame specFrame, BlockingQueue<Software> outputQueue, StepFrame nextFrame) {
		this(specFrame, outputQueue, nextFrame, specFrame.getSoftwareName());
	}
	
	public SpecificationStepWorker(SpecificationStepFrame frame,  BlockingQueue<Software> outputQueue, StepFrame nextFrame, String desiredName) {
		super(frame);
		this.outputQueue = outputQueue;
		this.nextFrame = nextFrame;
		this.desiredName = desiredName;
	}

	@Override
	protected Software doInBackground() throws Exception {
		SpecificationStep step = new SpecificationStep();
		this.software = step.doStep(this.desiredName);
		this.outputQueue.put(this.software);
		return this.software;
	}
	
	@Override
	protected void done() {
		super.done();
		this.nextFrame.getNextButton().setEnabled(true);
	}

}
